<% response.setHeader("X-UA-Compatible","IE=edge"); %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>设备信息管理平台</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="<%=basePath%>images/syzzicon.ico">
<link rel="stylesheet" href="<%=basePath%>css/syzzmain.css"  type="text/css" media="screen" />
<link rel="stylesheet" href="<%=basePath%>css/font-awesome.css" type="text/css" media="screen" />
<%-- <script type="text/javascript" src="<%=basePath%>js/jquery-1.11.3.js"></script> --%>
<SCRIPT language=javascript src="js/jquery-1.8.2.js"></SCRIPT>
<script src="<%=basePath%>js/Area.js" type="text/javascript"></script>
<script src="<%=basePath%>js/AreaData_min.js" type="text/javascript"></script>
<!--aui_dialog-->
<link rel="stylesheet" href="<%=basePath%>css/art_default.css" type="text/css" />
<script type="text/javascript" src="<%=basePath%>js/artDialog/jquery.artDialog.js"></script>
<script type="text/javascript" src="<%=basePath%>js/artDialog/jquery.artDialog.source.js"></script>

<link rel="stylesheet" href="<%=basePath%>css/css/zTreeStyle/zTreeStyle.css"
	type="text/css">

<SCRIPT language=javascript src="js/jquery.ztree.all-3.4.js"></SCRIPT>
<SCRIPT language=javascript src="js/jquery.ztree.core-3.4.js"></SCRIPT>
<SCRIPT language=javascript src="js/jquery.ztree.excheck-3.4.js"></SCRIPT>
<SCRIPT language=javascript src="js/jquery.ztree.exedit-3.4.js"></SCRIPT>
<SCRIPT language=javascript src="js/jquery.ztree.exhide-3.4.js"></SCRIPT>
</head>
<body>
<div class="main">
<form action="selectAllUser.action" method="post"  id="regForm">
  <div class="ycdh"><i class="icon-map-marker"></i>您所在位置：<a href="#">人员管理</a>&gt;&gt;<a href="#">角色管理</a></div>
  <div class="rightcontent">
    <div class="rightbt">角色管理</div>
    <!--操作栏目-->
    <div class="rightlm">
      <ul>
        <li> <span>搜索：</span>
          <div class="ssanbox"> 
			
	      	 <span>
	       
	    </span> <span> <select name="roleName">
										<option value="">请选择角色</option>
										<option value="普通员工">普通员工</option>
										<option value="经理">经理</option>
										<option value="经理及以上">经理及以上</option>
										<option value="管理者">管理者</option>
								</select>&nbsp;&nbsp;
								</span>
			<span>
            <input class="btn_blue w90" type="submit"  value="搜索">
            </span>
            
			
           
            
          </div>
        </li>
      </ul>
    </div>
    <!--操作栏目 end--> 
    <!--数据列表-->
    <div class="tablebox">
					<table class="tablelist">
						<colgroup>
							<col width="10%">
							<col width="12%">
							<col width="12%">
							<col width="14%">
							<col width="14%">
							<col width="18%">
							<col width="20%">
						</colgroup>
						<thead>
							<tr>
								<th>序号</th>
								<th>角色名</th>
								<th>角色详情</th>
								<th>操作</th>
							</tr>
						</thead>
						<c:forEach items="${list}" var="role1">
							<tr style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
								<td>${role1.id}</td>
								<td>${role1.rolename}</td>
								<td>${role1.roledetail}</td>
								<td><a href="javascript:;" onclick="authority(${role1.id})">设置权限</a></td>	
							</tr>
						</c:forEach>
					</table>
				</div>
 		 </div>
  </form>
  


  
 <div class="zTreeDemoBackground left"  id="authority" style="width: 300px;display:none" >  
	<ul id="user_tree" class="ztree" style="border: 1px solid #617775;overflow-y: scroll;height: 300px;"></ul>  
</div> 
</div>

<script type="text/javascript">
window.onload=function(){
	var area="${sse.area}";
	if(area!=null&&area.length>3)
	  initComplexArea('seachprov', 'seachcity', 'seachdistrict', area_array, sub_array, '61', area, '0');
	else
		initComplexArea('seachprov', 'seachcity', 'seachdistrict', area_array, sub_array, '61', '', '0');
}

function authority(roleid){
	
	document.getElementById('authority').setAttribute('display', "");
 	$.dialog({
		title : '权限管理',
		content:document.getElementById('authority'),//内容
		lock:true,
		ok:function(){
			document.getElementById('authority').setAttribute('display', "none");
			var ids="";
	          var treeObj=$.fn.zTree.getZTreeObj("user_tree"),
	            nodes=treeObj.getCheckedNodes(true),
	            v="";
	            for(var i=0;i<nodes.length;i++){
	            	v+=nodes[i].name + ",";
	            	ids+=","+nodes[i].id;
	            }
	            
	            $.ajax({
	        		type:'post',
	        		url :"<%=basePath%>addAuthority.action",
	        		data : {
	        			'roleid' : roleid,
	        			'authorityid':ids
	        		},
	        		dataType : "json",
	        		success : function(data) {
	        		}
	        	});
		},
		cancel:function(){
			document.getElementById('authority').setAttribute('display', "none");
		}
	}); 
 	
}

var zTree;  
var setting = {  
    view: {  
        dblClickExpand: false,//双击节点时，是否自动展开父节点的标识  
        showLine: true,//是否显示节点之间的连线  
        fontCss:{'color':'black','font-weight':'bold'},//字体样式函数  
        selectedMulti: false //设置是否允许同时选中多个节点  
    },  
    check:{  
        //chkboxType: { "Y": "ps", "N": "ps" },  
        chkStyle: "checkbox",//复选框类型  
        enable: true //每个节点上是否显示 CheckBox   
    },  
    data: {  
        simpleData: {//简单数据模式  
            enable:true,  
            idKey: "id",  
            pIdKey: "pid",  
            rootPId: ""  
        }  
    },  
    callback: {  
        beforeClick: function(treeId, treeNode) {  
            zTree = $.fn.zTree.getZTreeObj("user_tree");  
            if (treeNode.isParent) {  
                zTree.expandNode(treeNode);//如果是父节点，则展开该节点  
            }else{  
                zTree.checkNode(treeNode, !treeNode.checked, true, true);//单击勾选，再次单击取消勾选  
            }  
        }  
    }  
};  

//页面初始化
$(document).ready(function(){
	onLoadZTree();
});

//加载树形结构数据
function onLoadZTree(){
	
	 $.ajax({
		async:false,//是否异步
		cache:false,//是否使用缓存
		type:'post',
		url :"<%=basePath%>jsondong.action",
		data : {
			'userid' : 1
		},
		dataType : "json",
		success : function(data) {
			var treeNodes = jQuery.parseJSON(data);
				var t = $("#user_tree");  
			    t = $.fn.zTree.init(t, setting, data);
			
		}
	});
	
  
}

</script>
</body>
</html>

